﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace ZHDJ.Data.BLL
{
    public class IpHelper
    {
        public static string IpHelperMain(string args)
        {
            return Main(args);
        }

        private static string Main(string args)
        {
            var getIpInfoUrl = "http://ip.taobao.com/service/getIpInfo.php?ip={0}";
            getIpInfoUrl = string.Format(getIpInfoUrl, args);

            var client = new WebClient();
            var result = client.DownloadString(getIpInfoUrl);

            var json = Newtonsoft.Json.JsonConvert.DeserializeObject<IpInfo>(result);
            //Console.WriteLine(json.Data.Isp);
            return json.Data.Isp;

        }



        public class IpInfo
        {
            public int code { get; set; }

            public DataInfo Data { get; set; }

        }

        public class DataInfo
        {
            public string Isp { get; set; }
        }
    }
}
